﻿using K9Nano.Dependency;
using Microsoft.Extensions.Logging;

namespace K9Nano.Pushing;

/// <summary>
/// 仅用于测试
/// </summary>
/// <param name="logger"></param>
internal class NullSmsSender(ILogger<NullSmsSender> logger) : ISmsSender, ISingletonDependency
{
    public ValueTask<bool> SendAsync(string phone, string message, CancellationToken cancellation)
    {
        logger.LogInformation("SMS sended: {Phone}, code: {Message}", phone, message);
        return ValueTask.FromResult(true);
    }

    public ValueTask<bool> SendTemplateAsync(string phone, string temlateId, string[] tempateParams, CancellationToken cancellation)
    {
        var paramsString = tempateParams?.Length > 0
           ? string.Join("\",\"", tempateParams)
           : "[\"\"]";
        logger.LogInformation("Template SMS sending: {Phone}, TemlateId: {TemlateId}, Params: {Params}",
            phone, temlateId, paramsString);
        return ValueTask.FromResult(true);
    }
}